import Vue from 'vue'
import Vuex from 'vuex'
import { fetchEndpoint, fetchPageConfig } from './api'
import news from './modules/news'
import activity from './modules/activity'
import article from './modules/article'
import product from './modules/product'
import productDetail from './modules/productDetail'

Vue.use(Vuex)

const store = new Vuex.Store({
  strict: process.env.NODE_ENV === 'dev',
  modules: {
    news,
    activity,
    article,
    product,
    productDetail
  },

  actions: {
    FETCH_ENDPOINT_DATA: (context, { endpoint, params }) => {
      return fetchEndpoint(endpoint, params)
    },

    FETCH_PAGE_CONFIG: (context, { page }) => {
      return fetchPageConfig(page)
    }
  }
})

export default store